﻿using Entity.WMS.DTO.WarehouseStocktaking;
using Entity.WMS.View.WarehouseStocktaking;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Service.WMS;

namespace AnQinManagermentBackendAPI.Controller.WMS
{
    /// <summary>
    /// 库存盘点表
    /// </summary>
    [Route("api/[controller]")]
    [ApiController]
    [Authorize]
    public class WarehouseStocktakingController : ControllerBase
    {
        /**
         * 库存盘点业务接口
         */
        private readonly WarehouseStocktakingService _warehouseStocktakingService;

        /**
         * 构造函数注入
         */
        public WarehouseStocktakingController(WarehouseStocktakingService warehouseStocktakingService)
        {
            _warehouseStocktakingService = warehouseStocktakingService;
        }

        /// <summary>
        /// 获取库存盘点列表
        /// </summary>
        /// <param name="warehouseStocktakingSearchDTO"></param>
        [HttpGet]
        [ProducesResponseType(typeof(WarehouseStocktakingView), 200)]
        public async Task<IActionResult> GetWarehouseStocktakingList([FromQuery] WarehouseStocktakingSearchDTO warehouseStocktakingSearchDTO)
        {
            var response = await _warehouseStocktakingService.GetWarehouseStocktakingList(warehouseStocktakingSearchDTO);
            return StatusCode(response.Status, response);
        }

        /// <summary>
        /// 获取库存盘点子单列表
        /// </summary>
        /// <param name="warehouseStocktakingItemSearchDTO"></param>
        [HttpGet("item")]
        [ProducesResponseType(typeof(WarehouseStocktakingItemView), 200)]
        public async Task<IActionResult> GetWarehouseStocktakingItemList([FromQuery] WarehouseStocktakingItemSearchDTO warehouseStocktakingItemSearchDTO)
        {
            var response = await _warehouseStocktakingService.GetWarehouseStocktakingItemList(warehouseStocktakingItemSearchDTO);
            return StatusCode(response.Status, response);
        }

        /// <summary>
        /// 新增库存盘点
        /// </summary>
        /// <param name="warehouseStocktakingAddDTO"></param>
        [HttpPost]
        public async Task<IActionResult> AddWarehouseStocktaking([FromBody] WarehouseStocktakingAddDTO warehouseStocktakingAddDTO)
        {
            var response = await _warehouseStocktakingService.AddWarehouseStocktaking(warehouseStocktakingAddDTO);
            return StatusCode(response.Status, response);
        }

        /// <summary>
        /// 删除库存盘点
        /// </summary>
        [HttpDelete]
        public async Task<IActionResult> DeleteWarehouseStocktaking([FromBody] string Id)
        {
            var response = await _warehouseStocktakingService.DeleteWarehouseStocktaking(Id);
            return StatusCode(response.Status, response);
        }

        /// <summary>
        /// 审核通过库存盘点
        /// </summary>
        [HttpPost("Pass")]
        public async Task<IActionResult> PassWarehouseStocktaking([FromBody] string Id)
        {
            var response = await _warehouseStocktakingService.PassWarehouseStocktaking(Id);
            return StatusCode(response.Status, response);
        }

        /// <summary>
        /// 审核不通过库存盘点
        /// </summary>
        [HttpPost("UnPass")]
        public async Task<IActionResult> UnPassWarehouseStocktaking([FromBody] string Id)
        {
            var response = await _warehouseStocktakingService.UnPassWarehouseStocktaking(Id);
            return StatusCode(response.Status, response);
        }

        /// <summary>
        /// 反审核库存盘点
        /// </summary>
        [HttpPost("CancelPass")]
        public async Task<IActionResult> CancelWarehouseStocktaking([FromBody] string Id)
        {
            var response = await _warehouseStocktakingService.CancelPassWarehouseStocktaking(Id);
            return StatusCode(response.Status, response);
        }
    }
}
